package cn.anlab.anappframe.demo.activity;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ScrollView;
import cn.anlab.anappframe.R;

public class ActivityGroupDemoActivity extends ActivityGroup implements OnClickListener {

	ScrollView sv;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_group);
		
		Button btn1 = (Button) findViewById(R.id.button1);
		Button btn2 = (Button) findViewById(R.id.button2);
		Button btn3 = (Button) findViewById(R.id.button3);
		btn1.setOnClickListener(this);
		btn2.setOnClickListener(this);
		btn3.setOnClickListener(this);
		
		sv = (ScrollView) findViewById(R.id.container);
		
		
	}

	@Override
	public void onClick(View v) {
		sv.removeAllViews();
		Intent intent;
		Window win;
		View view;
		switch (v.getId()) {
		case R.id.button1:
			intent = new Intent(ActivityGroupDemoActivity.this, DimensActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			win = getLocalActivityManager().startActivity("Module1", intent);
			view = win.getDecorView();
			sv.addView(view);
			break;
		case R.id.button2:
			intent = new Intent(ActivityGroupDemoActivity.this, ChatDemoActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			win = getLocalActivityManager().startActivity("Module2", intent);
			view = win.getDecorView();
			sv.addView(view);
			
			break;
		case R.id.button3:
			intent = new Intent(ActivityGroupDemoActivity.this, ListViewDemoActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			win = getLocalActivityManager().startActivity("Module2", intent);
			view = win.getDecorView();
			sv.addView(view);
			break;
		}
		
	}
	
}
